home *** CD-ROM | disk | FTP | other *** search
- {*************************************************************************
-
- DemoMous.PAS Copyright 1994 Rob W. Smetana
-
- Demonstrate how to:
-
- 1. Change MOUSE CURSOR SHAPES in TEXT MODE!
-
- 2. Control the COLOR of the mouse cursor.
-
- 3. Use other Font Pak mouse routines:
-
- - Initialize the mouse: Function rsThereIsAMouse
- - Turn mouse cursor on/off: Procedure rsShowcursor
- Procedure rsHidecursor
- - Poll for mouse movement/click: Function rsButtonPressed
-
- 4. Using Font_Pak.Pas to declare all Font Pak routines -- except
- callable OBJ fonts.
-
-
- IMPORTANT: Most assembler routines REQUIRE that parameters be passed
- by value. BUT... 1 routine, rsButtonPressed, requires
- that TWO parameters be passed by REFERENCE -- so we can
- update those parameters.
-
- *************************************************************************}
-
-
- uses CRT, Font_Pak; {use Font_Pak.Pas to declare everything}
-
- var
- Block, WhichShape, ASCIICode, FG, BG: Integer; { mouse cursor shapes }
- Button, LastButton, Row, Col, GFXorText: Integer; { mouse movement/clicks }
- LastRow, LastCol: Integer; { track mouse movement }
- Ch : Char;
-
- Procedure DisplayGrid; { Put a grid on the screen }
-
- Begin
-
- rsHidecursor; { turn cursor off when updating screen }
- WriteLn (' Notice the mouse cursor. And watch what happens to it as you move the mouse');
- WriteLn (' around the CENTER of this grid. Also, HOLD DOWN a button and move around.');
-
- For Row := 6 to 22 do
- begin
- gotoxy(39,Row);
- Write ('│');
- end;
-
- gotoxy(8,13);
- WriteLn ('───────────────────────────────┼───────────────────────────────');
- rsShowcursor; { make the mouse cursor visible }
-
- end;
-
-
- begin
-
- TextAttr := 31; ClrScr;
-
- fpInitialize; ClrScr; {needed in shareware versions only}
-
- FG := Num16Shapes; BG := Num8Shapes; {use FG and BG temporarily}
-
- WriteLn (' There are ',FG,' 16-point mouse shapes you may choose from. There are also');
- WriteLn (' ',BG,' 8-point shapes. Press a key to continue.');
- Ch := ReadKey;
-
- ClrScr;
- Block := 0; {Use Block temporarily}
- Block := rsThereIsAMouse; {Is there a mouse? If so, initialize.}
-
- If Block = 0 then {0 = no mouse, -1 = there is a mouse }
- Begin
- WriteLn ('Sorry. This demo requires a mouse/mouse driver. I found none.');
- Ch := ReadKey;
- Halt;
- End;
-
-
- DisplayGrid; { display a grid }
-
-
- { now pre-load 4 mouse cursor shapes by changing the shapes of ASCII 1-4 }
-
- Block := 0; { use Block 0 }
-
- For ASCIICode := 1 to 4 do
- Begin
- WhichShape := ASCIICode;
- rsLoadMouseCursor (Block, WhichShape, ASCIICode);
- end;
-
-
- { Now loop and change MOUSE CURSOR SHAPES and COLORS. Press any key to end.}
-
- FG :=15; { if you hold down a button, we'll }
- BG :=4; { change mouse colors to white on red}
-
- { First show what the normal mouse cursor looks like. }
-
- Gotoxy(16,4); Write ('Here''s the NORMAL cursor. Click a mouse button.');
-
- GFXorText := 0; { 0 tells rsButtonPressed to return }
- { text-mode Row & Col; <>0 = Graphics}
-
- { Set GFXorText := 0 to tell rsButtonPressed to return text-mode }
- { Row & Col; <> 0 = return graphics coordinates. Use ONLY 0 here! }
- { This demo requires 25 row x 80 column screen coordinates. }
-
- GFXorText := 0;
-
- rsShowCursor; { turn ON the mouse cursor }
- Button := 0;
- Repeat
- Button := rsButtonPressed (Row, Col, GFXorText);
- Until Button > 0;
-
- { Initialize LastRow and LastCol before we enter our main loop. }
-
- LastRow := Row; LastCol := Col;
-
- Gotoxy(5,25); Write (' ');
- Gotoxy(16,4);WriteLn (' Press Escape or Enter to end this demo. ');
- Gotoxy(60,25); Write ('Row: Col: ');
-
- {
- Loop until you press a key. While looping, track where the mouse
- cursor is and if a button is pressed. Change the shape and color
- of the mouse cursor accordingly.
- }
-
- LastButton := 0; {wait for a button press to show 1st cursor}
-
- ASCIICode := 1;
- rsSetTextCursorC (ASCIICode);
-
- Repeat
-
- Button := rsButtonPressed (Row, Col, GFXorText);
-
- {If we move the mouse or press a button, change shapes or colors.}
-
- If (LastButton > 0) and ((LastRow <> Row) or (LastCol <> Col)) then
- Begin
-
- Gotoxy(65,25); Write (Row,' ');
- Gotoxy(75,25); Write (Col,' ');
-
- If Row > 12 then { use a downward pointing arrow }
-
- Begin
- If Col > 39
- then ASCIICode := 4
- else
- ASCIICode := 2;
- end
-
- else { use an upward pointing arrow }
- Begin
- If Col > 39
- then ASCIICode := 3
- else
- ASCIICode := 1;
- end;
-
- { Tell the mouse driver to use ASCII char. ASCIICode as cursor shape }
-
- rsSetTextCursorC (ASCIICode);
-
- LastRow := Row;
- LastCol := Col;
- end;
-
- {
- If a button was pressed (or is held down) change the cursor color.
- Note: The mouse will flicker if you hold it down. We could
- eliminate flicker, but doing so wouldn't let us show you how the
- mouse shape/color changes if you move across a grid boundary.
- }
-
- If Button > 0 then
-
- Begin
-
- { use different colors while the button is held down }
- rsSetTextCursor (FG, BG, ASCIICode);
-
- If Button <> LastButton then
-
- Begin
-
- LastButton := Button;
- Gotoxy(5,25); Write ('You pressed ');
-
- case Button of
- 1: Write ('the Left button. ');
- 2: Write ('the Right button. ');
- 4: Write ('the Middle button.');
- 3: Write ('2 buttons. ');
- end; {case}
-
- end;
- end;
-
- Until Keypressed;
-
- rsHidecursor; { turn it off }
- TextMode(3); { an easy way to restore default font }
-
- end.
-